package com.bestv.search.common.service.impl;

import com.bestv.search.common.dao.SiteDao;
import com.bestv.search.common.dataSource.DataSourceKey;
import com.bestv.search.common.model.Site;
import com.bestv.search.common.service.SiteManager;
import com.bestv.search.common.util.CommandException;

import java.util.List;

public class SiteManagerImpl implements SiteManager {
    private SiteDao siteDao;

    public SiteDao getSiteDao() {
        return siteDao;
    }

    public void setSiteDao(SiteDao siteDao) {
        this.siteDao = siteDao;
    }

    @Override
    public Site getSiteByCode(DataSourceKey key, String code) {
        return siteDao.getSiteByCode(code);
    }

    @Override
    public List<Site> getSitesByCodes(DataSourceKey key, String[] codes) {
        return siteDao.getSitesByCodes(codes);
    }

    @Override
    public Site getSiteById(DataSourceKey key, Long id) {
        return siteDao.get(id);
    }

    @Override
    public Site getSiteByName(DataSourceKey key, String name) {
        return siteDao.getSiteByName(name);
    }

    @Override
    public List<Site> getSites(DataSourceKey key) {
        return siteDao.getAll();
    }

    @Override
    public Site saveSite(DataSourceKey key, Site site) {
        return siteDao.save(site);
    }

    @Override
    public void deleteSite(DataSourceKey key, Long id) throws CommandException {
        siteDao.remove(id);
    }

    @Override
    public List<Site> getSitesExpHDQ(DataSourceKey key) {
        return siteDao.getSitesExpHDQ();
    }
}
